#! /usr/bin/env python

from pygame.locals import *

import pygame

# initialise pygame before we import anything else
pygame.mixer.pre_init(44100, -16, 2, 1024)
pygame.init()

import gravity

FRAMES_PER_SEC = 60

def playMain():
    currentState = gravity.startGame()
    clock = pygame.time.Clock()    
    while True:
        clock.tick(FRAMES_PER_SEC)
        for event in pygame.event.get():
            if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
                return                   
        keyPresses = pygame.key.get_pressed()        
        newState = currentState.execute(keyPresses)
        if newState:
            currentState = newState

if __name__ == '__main__': playMain()
